using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
namespace LabMS.Web.CoursePlan
{
    public partial class ProDictionary : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) 
            {
                //chk_All.Attributes.Add("onclick", "checkAllChanged(this,'Gv_Pro')");
                DataBinds();
            }

        }

        protected void DataBinds() 
        {
            Gv_DataBind();
        }

        protected void Gv_DataBind() 
        {
            LabMS.BLL.Professional Pro = new LabMS.BLL.Professional();
            List<LabMS.Model.Professional> ls = new List<LabMS.Model.Professional>();
            ls = Pro.GetModelList(CombineStr());
            Gv_Pro.DataSource = ls;
            Gv_Pro.DataBind();
            
        }

        protected string CombineStr() 
        {
            string strWhere = "";
            if (ddl_SearchType.SelectedValue == "0"&& !string.IsNullOrEmpty(tb_KeyWord.Text.Trim())) 
            {
                strWhere += "Pro_Code like '%" + tb_KeyWord.Text.Trim() + "%'";
            }
            else if (ddl_SearchType.SelectedValue == "1" && !string.IsNullOrEmpty(tb_KeyWord.Text.Trim())) 
            {
                strWhere += "Pro_Name like '%" + tb_KeyWord.Text.Trim() + "%'";
            }
            return strWhere;
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Gv_DataBind();
        }

        protected void Gv_Pro_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            e.Row.Attributes["style"] = "Cursor:pointer";
        }


        protected void Gv_Pro_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            e.NewPageIndex = Gv_Pro.PageIndex;
            Gv_DataBind();
            

        }



    }
}
